<?php

include_once("model/Model.php");

class Controller {
	public $model;
	
	public function __construct()  
    {  
        $this->model = new Model();

    } 
	
	public function invoke($_REQUEST)
	{
		$femaleRequest = $this->model->getFemaleFriendReq();
		print_r($femaleRequest);
		$maleRequest = $this->model->getMaleFriendReq();
		print_r($maleRequest);
		if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'login')
		{
			// if login id and password submitted
			$loginError = $this->model->login($_REQUEST['user'],$_REQUEST['pass']);
		}
		else if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'register')
		{
			// if registration data submitted
			$registerError = $this->model->register($_REQUEST['name'],$_REQUEST['user'],$_REQUEST['pass']);
		}
		
		else if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'msgsubmit')
		{
			// if registration data submitted
			$mess = $this->model->msgsubmit($_REQUEST['message']);
		}
		
		else if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'submitmandatoryData')
		{
			// if registration data submitted
			$registerError = $this->model->submitMandatoryData($_REQUEST['city'],$_REQUEST['dob'],$_REQUEST['gender']);
		}
		else if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'statusUpdate')
		{
			$statusError = $this->model->statusUpdate($_REQUEST['status'],$_REQUEST['privacy']);
		}
		else if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'logout')
		{
			$statusError = $this->model->logout();
		}
		else if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'showComment')
		{
			$comments = $this->model->getStatusComment($_REQUEST['id']);
		}
		else if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'showReply')
		{
			$comments = $this->model->getCommentReply($_REQUEST['id']);
		}
		else if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'sendReply')
		{
			$comments = $this->model->sendCommentReply($_REQUEST['id'],$_REQUEST['text']);
		}
		else if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'sendComment')
		{
			$comments = $this->model->sendComment($_REQUEST['id'],$_REQUEST['text']);
		}
		else if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'likeStatus')
		{
			$comments = $this->model->likeStatus($_REQUEST['id']);
		}
		else if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'unlikeStatus')
		{
			$comments = $this->model->unlikeStatus($_REQUEST['id']);
		}
		else if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'dislikeStatus')
		{
			$comments = $this->model->dislikeStatus($_REQUEST['id']);
		}
		else if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'undislikeStatus')
		{
			$comments = $this->model->undislikeStatus($_REQUEST['id']);
		}
		else if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'likeComment')
		{
			$comments = $this->model->likeComment($_REQUEST['id']);
		}
		else if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'unlikeComment')
		{
			$comments = $this->model->unlikeComment($_REQUEST['id']);
		}
		else if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'dislikeComment')
		{
			$comments = $this->model->dislikeComment($_REQUEST['id']);
		}
		else if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'undislikeComment')
		{
			$comments = $this->model->undislikeComment($_REQUEST['id']);
		}
		else if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'likeReply')
		{
			$comments = $this->model->likeReply($_REQUEST['id']);
		}
		else if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'unlikeReply')
		{
			$comments = $this->model->unlikeReply($_REQUEST['id']);
		}
		else if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'dislikeReply')
		{
			$comments = $this->model->dislikeReply($_REQUEST['id']);
		}
		else if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'undislikeReply')
		{
			$comments = $this->model->undislikeReply($_REQUEST['id']);
		}
		else if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'shareStatus')
		{
			$comments = $this->model->shareStatus($_REQUEST['id']);
		}
		else if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'showFriendPage')
		{
			$userDetail = $this->model->getUserDetail($_REQUEST['id']);
			$userFriendShip = $this->model->getFriendship($_REQUEST['id']);
			$friends = $this->model->getFriendList($_REQUEST['id']);
			$friendName = $this->model->getFriendName($_REQUEST['id']);
			
			if($friends != 0)
				$friendsCount = count($friends);
			else
				$friendsCount = 0;
			include("view/friendspage.php");

		}
		
		else if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'sendMsg')
		{
			$userDetail = $this->model->getUserDetail($_REQUEST['id']);
			$userFriendShip = $this->model->getFriendship($_REQUEST['id']);
			$friends = $this->model->getFriendList($_REQUEST['id']);
			if($friends != 0)
				$friendsCount = count($friends);
			else
				$friendsCount = 0;
			include("view/writeMessage.php");

		}
		
		
		
		else if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'showprofile')
		{
			$userDetail = $this->model->getUserDetail($_SESSION['user_id']);
			$friends = $this->model->getFriendList($_SESSION['user_id']);
			$friendsCount = count($friends);
			include("view/profile.php");
		}
		
		else if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'showwall')
		{
			$userDetail = $this->model->getUserDetail($_SESSION['user_id']);
			$friends = $this->model->getFriendList($_SESSION['user_id']);
			$wallDetail = $this->model->wallDetail($_SESSION['user_id']);
			include("view/wall.php");
		}
		
		else if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'vault')
		{
			// if registration data submitted
            //$userDetail = $this->model->getUserDetail($_SESSION['user_id']);
            //$mess = $this->model->msgsubmit($_REQUEST['message'],$_REQUEST['fid']);
            //$albumDetail = $this->model->getAlbumDetails($_SESSION['user_id']);
            $albumDetail = $this->model->getImageAlbumDetails($_SESSION['user_id']);
			include("view/vault.php");
		}
		
		else if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'messages')
		{
			$userDetail = $this->model->getUserDetail($_SESSION['user_id']);
			$friends = $this->model->getFriendList($_SESSION['user_id']);
			$friendsCount = count($friends);
			$messages = $this->model->getMessages($_SESSION['user_id']);
			$reply = $this->model->getReply($_SESSION['user_id']);
			
			
			include("view/messages.php");
		}
		else if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'reply')
		{
			$userDetail = $this->model->getUserDetail($_SESSION['user_id']);
			$friends = $this->model->getFriendList($_SESSION['user_id']);
			$friendsCount = count($friends);
			$messages = $this->model->getMessages($_SESSION['user_id']);
			include("view/reply.php");
		}
		
		else if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'worldvault')
		{
			//$cat=$_POST['category'];
			$musicDetail = $this->model->getmusic($_SESSION['user_id']);
			$imgDetail = $this->model->getimg($_SESSION['user_id']);
			$videoDetail = $this->model->getvideo($_SESSION['user_id']);
			$docDetail = $this->model->getdoc($_SESSION['user_id']);
			$musicDetail = $this->model->getmusic($_SESSION['user_id'],$cat);
			
			//$muDetail = $this->model->getCatmusic();
			include("view/worldvault.php");
		}
		
		
		else if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'sendFriendRequest')
		{
			$userDetail = $this->model->sendFriendRequest($_REQUEST['id']);
		}
		else if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'editprofile')
		{
			// if registration data submitted
			$editprofileError = $this->model->editprofile($_REQUEST['dob'],$_REQUEST['gender']);
		}
		else if(isset($_SESSION['user_id']))
		{
			$userStatus = $this->model->getDashboardStatus();
			include("view/dashboard.php");
		}
		
		else if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'vaultImages')
		{
			include("view/vaultImages.php");
		}
		
		else if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'getvideos')
		{
			$videoDetail = $this->model->getvideos($_SESSION['user_id']);
		}
		
		else if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'getmusic')
		{
			$musicDetail = $this->model->getmusic($_SESSION['user_id']);
			include("view/worlvault.php");
		}
		
		else
		{
			include 'view/landing.php';
		}
	}
}

?>